package com.truthbean.jeetb.api.jaxrs.oschina;

import com.truthbean.jeetb.api.service.oschina.NewsService;

import javax.annotation.PostConstruct;
import javax.ws.rs.*;
import java.io.Serializable;

/**
 * Created by TruthBean on 2016-10-09 14:44.
 */
@Path("/oschina/news")
public class NewsResources implements Serializable {
    //Inject 无法在实例化之前注入
    private NewsService newsService;

    @PostConstruct
    public void init() {
        newsService = new NewsService();
    }

    @GET
    public String getNewsList() {
        return newsService.getNewsList(0);
    }

    @POST
    public String getNewsListPaged(@FormParam("curPage") int curPage) {
        return newsService.getNewsList(curPage);
    }

    @GET
    @Path("/{id}")
    public String getNewsDetail(@PathParam("id") int id){
        return newsService.getNewsDetailById(id);
    }
}
